﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using DataTools.Memory;
using DataTools.Interop;

namespace DataTools.Interop.Hardware
{

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    internal struct CTL_CODE
    {
        public uint Value;

        public uint DeviceType
        {
            get
            {
                return (this.Value & 0xffff0000) >> 16;
            }
        }

        public uint Method
        {
            get
            {
                return (this.Value & 3);
            }
        }

        public CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
        {
            this.Value = (DeviceType << 16) | (Access << 14) | (Function << 2) | Method;
        }

        public override String ToString()
        {
            return Value.ToString();
        }

        public static implicit operator uint(CTL_CODE c)
        {
            return c.Value;
        }

        public static implicit operator CTL_CODE(uint u)
        {
            CTL_CODE c = new CTL_CODE();
            c.Value = u;
            return c;
        }
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    internal struct STORAGE_DEVICE_NUMBER
    {
        public uint DeviceType;
        public uint DeviceNumber;
        public uint PartitionNumber;
    }

    internal static class IoCtl
    {

        [DllImport("kernel32.dll")]
        public static extern bool DeviceIoControl(
            IntPtr hDevice,
            uint DwIoControlCode,
            IntPtr lpInBuffer,
            uint nInBufferSize,
            IntPtr lpOutBuffer,
            uint nOutBufferSize,
            ref uint lpbytesreturned,
            IntPtr lpOverlapped);

        [DllImport("kernel32.dll")]
        public static extern bool DeviceIoControl(
            IntPtr hDevice,
            uint DwIoControlCode,
            IntPtr lpInBuffer,
            uint nInBufferSize,
            STORAGE_DEVICE_NUMBER lpOutBuffer,
            uint nOutBufferSize,
            ref uint lpbytesreturned,
            IntPtr lpOverlapped);

        public const uint IOCTL_DISK_BASE = 7;

        public const uint METHOD_BUFFERED = 0;
        public const uint METHOD_IN_DIRECT = 1;
        public const uint METHOD_OUT_DIRECT = 2;
        public const uint METHOD_NEITHER = 3;

        public const uint IOCTL_STORAGE_BASE = 0x2d;

        public const uint FILE_ANY_ACCESS = 0;
        public const uint FILE_SPECIAL_ACCESS = (FILE_ANY_ACCESS);
        public const uint FILE_READ_ACCESS = (1);    // file & pipe
        public const uint FILE_WRITE_ACCESS = (2);    // file & pipe

        public static readonly CTL_CODE IOCTL_STORAGE_CHECK_VERIFY = new CTL_CODE(IOCTL_STORAGE_BASE, 0x200, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_CHECK_VERIFY2 = new CTL_CODE(IOCTL_STORAGE_BASE, 0x200, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_MEDIA_REMOVAL = new CTL_CODE(IOCTL_STORAGE_BASE, 0x201, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_EJECT_MEDIA = new CTL_CODE(IOCTL_STORAGE_BASE, 0x202, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_LOAD_MEDIA = new CTL_CODE(IOCTL_STORAGE_BASE, 0x203, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_LOAD_MEDIA2 = new CTL_CODE(IOCTL_STORAGE_BASE, 0x203, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_RESERVE = new CTL_CODE(IOCTL_STORAGE_BASE, 0x204, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_RELEASE = new CTL_CODE(IOCTL_STORAGE_BASE, 0x205, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_FIND_NEW_DEVICES = new CTL_CODE(IOCTL_STORAGE_BASE, 0x206, METHOD_BUFFERED, FILE_READ_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_EJECTION_CONTROL = new CTL_CODE(IOCTL_STORAGE_BASE, 0x250, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_MCN_CONTROL = new CTL_CODE(IOCTL_STORAGE_BASE, 0x251, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_GET_MEDIA_TYPES = new CTL_CODE(IOCTL_STORAGE_BASE, 0x300, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_GET_MEDIA_TYPES_EX = new CTL_CODE(IOCTL_STORAGE_BASE, 0x301, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER = new CTL_CODE(IOCTL_STORAGE_BASE, 0x304, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_GET_HOTPLUG_INFO = new CTL_CODE(IOCTL_STORAGE_BASE, 0x305, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_SET_HOTPLUG_INFO = new CTL_CODE(IOCTL_STORAGE_BASE, 0x306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_RESET_BUS = new CTL_CODE(IOCTL_STORAGE_BASE, 0x400, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_RESET_DEVICE = new CTL_CODE(IOCTL_STORAGE_BASE, 0x401, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_BREAK_RESERVATION = new CTL_CODE(IOCTL_STORAGE_BASE, 0x405, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_PERSISTENT_RESERVE_IN = new CTL_CODE(IOCTL_STORAGE_BASE, 0x406, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_PERSISTENT_RESERVE_OUT = new CTL_CODE(IOCTL_STORAGE_BASE, 0x407, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_GET_DEVICE_NUMBER = new CTL_CODE(IOCTL_STORAGE_BASE, 0x420, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_PREDICT_FAILURE = new CTL_CODE(IOCTL_STORAGE_BASE, 0x440, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_FAILURE_PREDICTION_CONFIG = new CTL_CODE(IOCTL_STORAGE_BASE, 0x441, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_READ_CAPACITY = new CTL_CODE(IOCTL_STORAGE_BASE, 0x450, METHOD_BUFFERED, FILE_READ_ACCESS);

        //;
        // IOCTLs 0x0463 to 0x0468 reserved for dependent disk support.;
        //;

        //;
        // IOCTLs 0x0470 to 0x047f reserved for device and stack telemetry interfaces;
        //;

        public static readonly CTL_CODE IOCTL_STORAGE_GET_DEVICE_TELEMETRY = new CTL_CODE(IOCTL_STORAGE_BASE, 0x470, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_DEVICE_TELEMETRY_NOTIFY = new CTL_CODE(IOCTL_STORAGE_BASE, 0x471, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_DEVICE_TELEMETRY_QUERY_CAPS = new CTL_CODE(IOCTL_STORAGE_BASE, 0x472, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_GET_DEVICE_TELEMETRY_RAW = new CTL_CODE(IOCTL_STORAGE_BASE, 0x473, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_QUERY_PROPERTY = new CTL_CODE(IOCTL_STORAGE_BASE, 0x500, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES = new CTL_CODE(IOCTL_STORAGE_BASE, 0x501, METHOD_BUFFERED, FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_GET_LB_PROVISIONING_MAP_RESOURCES = new CTL_CODE(IOCTL_STORAGE_BASE, 0x502, METHOD_BUFFERED, FILE_READ_ACCESS);

        //;
        // IOCTLs 0x0503 to 0x0580 reserved for Enhanced Storage devices.;
        //;

        //;
        // IOCTLs for bandwidth contracts on storage devices;
        // (Move this to ntddsfio if we decide to use a new base);
        //;

        public static readonly CTL_CODE IOCTL_STORAGE_GET_BC_PROPERTIES = new CTL_CODE(IOCTL_STORAGE_BASE, 0x600, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_ALLOCATE_BC_STREAM = new CTL_CODE(IOCTL_STORAGE_BASE, 0x601, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_FREE_BC_STREAM = new CTL_CODE(IOCTL_STORAGE_BASE, 0x602, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        //;
        // IOCTL to check for priority support;
        //;
        public static readonly CTL_CODE IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT = new CTL_CODE(IOCTL_STORAGE_BASE, 0x620, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //;
        // IOCTL for data integrity check support;
        //;

        public static readonly CTL_CODE IOCTL_STORAGE_START_DATA_INTEGRITY_CHECK = new CTL_CODE(IOCTL_STORAGE_BASE, 0x621, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_STORAGE_STOP_DATA_INTEGRITY_CHECK = new CTL_CODE(IOCTL_STORAGE_BASE, 0x622, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        // begin_winioctl;

        //;
        // IOCTLs 0x0643 to 0x0655 reserved for VHD disk support.;
        //;

        //;
        // IOCTL to support Idle Power Management, including Device Wake;
        //;
        public static readonly CTL_CODE IOCTL_STORAGE_ENABLE_IDLE_POWER = new CTL_CODE(IOCTL_STORAGE_BASE, 0x720, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_GET_IDLE_POWERUP_REASON = new CTL_CODE(IOCTL_STORAGE_BASE, 0x721, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //;
        // IOCTLs to allow class drivers to acquire and release active references on;
        // a unit.  These should only be used if the class driver previously sent a;
        // successful IOCTL_STORAGE_ENABLE_IDLE_POWER request to the port driver.;
        //;
        public static readonly CTL_CODE IOCTL_STORAGE_POWER_ACTIVE = new CTL_CODE(IOCTL_STORAGE_BASE, 0x722, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE IOCTL_STORAGE_POWER_IDLE = new CTL_CODE(IOCTL_STORAGE_BASE, 0x723, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //;
        // This IOCTL indicates that the physical device has triggered some sort of event.;
        //;
        public static readonly CTL_CODE IOCTL_STORAGE_EVENT_NOTIFICATION = new CTL_CODE(IOCTL_STORAGE_BASE, 0x724, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public const uint IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = (((IOCTL_VOLUME_BASE) * (2 ^ 16)) | ((FILE_ANY_ACCESS) * (2 ^ 14)) | ((0) * (2 ^ 2)) | (METHOD_BUFFERED));
        public const uint IOCTL_VOLUME_BASE = 86;

        //;
        // IoControlCode values for disk devices.;
        //;

        public static readonly CTL_CODE IOCTL_DISK_GET_DRIVE_GEOMETRY = new CTL_CODE(IOCTL_DISK_BASE, 0x0, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_GET_PARTITION_INFO = new CTL_CODE(IOCTL_DISK_BASE, 0x1, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_SET_PARTITION_INFO = new CTL_CODE(IOCTL_DISK_BASE, 0x2, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_GET_DRIVE_LAYOUT = new CTL_CODE(IOCTL_DISK_BASE, 0x3, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_SET_DRIVE_LAYOUT = new CTL_CODE(IOCTL_DISK_BASE, 0x4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_VERIFY = new CTL_CODE(IOCTL_DISK_BASE, 0x5, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_FORMAT_TRACKS = new CTL_CODE(IOCTL_DISK_BASE, 0x6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_REASSIGN_BLOCKS = new CTL_CODE(IOCTL_DISK_BASE, 0x7, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_PERFORMANCE = new CTL_CODE(IOCTL_DISK_BASE, 0x8, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_IS_WRITABLE = new CTL_CODE(IOCTL_DISK_BASE, 0x9, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_LOGGING = new CTL_CODE(IOCTL_DISK_BASE, 0xA, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_FORMAT_TRACKS_EX = new CTL_CODE(IOCTL_DISK_BASE, 0xB, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_HISTOGRAM_STRUCTURE = new CTL_CODE(IOCTL_DISK_BASE, 0xC, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_HISTOGRAM_DATA = new CTL_CODE(IOCTL_DISK_BASE, 0xD, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_HISTOGRAM_RESET = new CTL_CODE(IOCTL_DISK_BASE, 0xE, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_REQUEST_STRUCTURE = new CTL_CODE(IOCTL_DISK_BASE, 0xF, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_REQUEST_DATA = new CTL_CODE(IOCTL_DISK_BASE, 0x10, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_PERFORMANCE_OFF = new CTL_CODE(IOCTL_DISK_BASE, 0x18, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //if(_WIN32_WINNT >= 0x0400);
        public static readonly CTL_CODE IOCTL_DISK_CONTROLLER_NUMBER = new CTL_CODE(IOCTL_DISK_BASE, 0x11, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //;
        // IOCTL support for SMART drive fault prediction.;
        //;

        public static readonly CTL_CODE SMART_GET_VERSION = new CTL_CODE(IOCTL_DISK_BASE, 0x20, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE SMART_SEND_DRIVE_COMMAND = new CTL_CODE(IOCTL_DISK_BASE, 0x21, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE SMART_RCV_DRIVE_DATA = new CTL_CODE(IOCTL_DISK_BASE, 0x22, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        //endif /* _WIN32_WINNT >= 0x0400 */;

        //if (_WIN32_WINNT >= 0x500);

        //;
        // New IOCTLs for GUID Partition tabled disks.;
        //;

        public static readonly CTL_CODE IOCTL_DISK_GET_PARTITION_INFO_EX = new CTL_CODE(IOCTL_DISK_BASE, 0x12, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_SET_PARTITION_INFO_EX = new CTL_CODE(IOCTL_DISK_BASE, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_GET_DRIVE_LAYOUT_EX = new CTL_CODE(IOCTL_DISK_BASE, 0x14, METHOD_BUFFERED, FILE_ANY_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_SET_DRIVE_LAYOUT_EX = new CTL_CODE(IOCTL_DISK_BASE, 0x15, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_CREATE_DISK = new CTL_CODE(IOCTL_DISK_BASE, 0x16, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_GET_LENGTH_INFO = new CTL_CODE(IOCTL_DISK_BASE, 0x17, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_GET_DRIVE_GEOMETRY_EX = new CTL_CODE(IOCTL_DISK_BASE, 0x28, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //endif /* _WIN32_WINNT >= 0x0500 */;

        //if (_WIN32_WINNT >= 0x0502);

        //;
        // New IOCTL for disk devices that support 8 byte LBA;
        //;
        public static readonly CTL_CODE IOCTL_DISK_REASSIGN_BLOCKS_EX = new CTL_CODE(IOCTL_DISK_BASE, 0x29, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        //End If //_WIN32_WINNT >= 0x0502;

        //if(_WIN32_WINNT >= 0x0500);
        public static readonly CTL_CODE IOCTL_DISK_UPDATE_DRIVE_SIZE = new CTL_CODE(IOCTL_DISK_BASE, 0x32, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        public static readonly CTL_CODE IOCTL_DISK_GROW_PARTITION = new CTL_CODE(IOCTL_DISK_BASE, 0x34, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        public static readonly CTL_CODE IOCTL_DISK_GET_CACHE_INFORMATION = new CTL_CODE(IOCTL_DISK_BASE, 0x35, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_SET_CACHE_INFORMATION = new CTL_CODE(IOCTL_DISK_BASE, 0x36, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        //If (NTDDI_VERSION < NTDDI_WS03) Then;
        public static readonly CTL_CODE IOCTL_DISK_GET_WRITE_CACHE_STATE = new CTL_CODE(IOCTL_DISK_BASE, 0x37, METHOD_BUFFERED, FILE_READ_ACCESS);

        //Else;
        public static readonly CTL_CODE OBSOLETE_DISK_GET_WRITE_CACHE_STATE = new CTL_CODE(IOCTL_DISK_BASE, 0x37, METHOD_BUFFERED, FILE_READ_ACCESS);

        //End If;
        public static readonly CTL_CODE IOCTL_DISK_DELETE_DRIVE_LAYOUT = new CTL_CODE(IOCTL_DISK_BASE, 0x40, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);

        //;
        // Called to flush cached information that the driver may have about this;
        // device's characteristics.  Not all drivers cache characteristics, and not;
        // cached properties can be flushed.  This simply serves as an update to the;
        // driver that it may want to do an expensive reexamination of the device's;
        // characteristics now (fixed media size, partition table, etc...);
        //;

        public static readonly CTL_CODE IOCTL_DISK_UPDATE_PROPERTIES = new CTL_CODE(IOCTL_DISK_BASE, 0x50, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //;
        //  Special IOCTLs needed to support PC-98 machines in Japan;
        //;

        public static readonly CTL_CODE IOCTL_DISK_FORMAT_DRIVE = new CTL_CODE(IOCTL_DISK_BASE, 0xF3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_SENSE_DEVICE = new CTL_CODE(IOCTL_DISK_BASE, 0xF8, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //endif /* _WIN32_WINNT >= 0x0500 */;

        //;
        // The following device control codes are common for all class drivers.  The;
        // functions codes defined here must match all of the other class drivers.;
        //;
        // Warning: these codes will be replaced in the future by equivalent;
        // IOCTL_STORAGE codes;
        //;

        public static readonly CTL_CODE IOCTL_DISK_CHECK_VERIFY = new CTL_CODE(IOCTL_DISK_BASE, 0x200, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_MEDIA_REMOVAL = new CTL_CODE(IOCTL_DISK_BASE, 0x201, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_EJECT_MEDIA = new CTL_CODE(IOCTL_DISK_BASE, 0x202, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_LOAD_MEDIA = new CTL_CODE(IOCTL_DISK_BASE, 0x203, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_RESERVE = new CTL_CODE(IOCTL_DISK_BASE, 0x204, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_RELEASE = new CTL_CODE(IOCTL_DISK_BASE, 0x205, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_FIND_NEW_DEVICES = new CTL_CODE(IOCTL_DISK_BASE, 0x206, METHOD_BUFFERED, FILE_READ_ACCESS);
        public static readonly CTL_CODE IOCTL_DISK_GET_MEDIA_TYPES = new CTL_CODE(IOCTL_DISK_BASE, 0x300, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //;

        public static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);

        public const uint DELETE = (0x10000);
        public const uint READ_CONTROL = (0x20000);
        public const uint WRITE_DAC = (0x40000);
        public const uint WRITE_OWNER = (0x80000);
        public const uint SYNCHRONIZE = (0x100000);

        public const uint STANDARD_RIGHTS_REQUIRED = (0xF0000);

        public const uint STANDARD_RIGHTS_READ = (READ_CONTROL);
        public const uint STANDARD_RIGHTS_WRITE = (READ_CONTROL);
        public const uint STANDARD_RIGHTS_EXECUTE = (READ_CONTROL);

        public const uint STANDARD_RIGHTS_ALL = (0x1F0000);

        public const uint SPECIFIC_RIGHTS_ALL = (0xFFFF);

        //
        // AccessSystemAcl access type
        //

        public const uint ACCESS_SYSTEM_SECURITY = (0x1000000);

        //
        // MaximumAllowed access type
        //

        public const uint MAXIMUM_ALLOWED = (0x2000000);

        //

        public const uint FILE_DEVICE_BEEP = 0x1;
        public const uint FILE_DEVICE_CD_ROM = 0x2;
        public const uint FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x3;
        public const uint FILE_DEVICE_CONTROLLER = 0x4;
        public const uint FILE_DEVICE_DATALINK = 0x5;
        public const uint FILE_DEVICE_DFS = 0x6;
        public const uint FILE_DEVICE_DISK = 0x7;
        public const uint FILE_DEVICE_DISK_FILE_SYSTEM = 0x8;
        public const uint FILE_DEVICE_FILE_SYSTEM = 0x9;
        public const uint FILE_DEVICE_INPORT_PORT = 0xA;
        public const uint FILE_DEVICE_KEYBOARD = 0xB;
        public const uint FILE_DEVICE_MAILSLOT = 0xC;
        public const uint FILE_DEVICE_MIDI_IN = 0xD;
        public const uint FILE_DEVICE_MIDI_OUT = 0xE;
        public const uint FILE_DEVICE_MOUSE = 0xF;
        public const uint FILE_DEVICE_MULTI_UNC_PROVIDER = 0x10;
        public const uint FILE_DEVICE_NAMED_PIPE = 0x11;
        public const uint FILE_DEVICE_NETWORK = 0x12;
        public const uint FILE_DEVICE_NETWORK_BROWSER = 0x13;
        public const uint FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x14;
        public const uint FILE_DEVICE_NULL = 0x15;
        public const uint FILE_DEVICE_PARALLEL_PORT = 0x16;
        public const uint FILE_DEVICE_PHYSICAL_NETCARD = 0x17;
        public const uint FILE_DEVICE_PRINTER = 0x18;
        public const uint FILE_DEVICE_SCANNER = 0x19;
        public const uint FILE_DEVICE_SERIAL_MOUSE_PORT = 0x1A;
        public const uint FILE_DEVICE_SERIAL_PORT = 0x1B;
        public const uint FILE_DEVICE_SCREEN = 0x1C;
        public const uint FILE_DEVICE_SOUND = 0x1D;
        public const uint FILE_DEVICE_STREAMS = 0x1E;
        public const uint FILE_DEVICE_TAPE = 0x1F;
        public const uint FILE_DEVICE_TAPE_FILE_SYSTEM = 0x20;
        public const uint FILE_DEVICE_TRANSPORT = 0x21;
        public const uint FILE_DEVICE_UNKNOWN = 0x22;
        public const uint FILE_DEVICE_VIDEO = 0x23;
        public const uint FILE_DEVICE_VIRTUAL_DISK = 0x24;
        public const uint FILE_DEVICE_WAVE_IN = 0x25;
        public const uint FILE_DEVICE_WAVE_OUT = 0x26;
        public const uint FILE_DEVICE_8042_PORT = 0x27;
        public const uint FILE_DEVICE_NETWORK_REDIRECTOR = 0x28;
        public const uint FILE_DEVICE_BATTERY = 0x29;
        public const uint FILE_DEVICE_BUS_EXTENDER = 0x2A;
        public const uint FILE_DEVICE_MODEM = 0x2B;
        public const uint FILE_DEVICE_VDM = 0x2C;
        public const uint FILE_DEVICE_MASS_STORAGE = 0x2D;
        public const uint FILE_DEVICE_SMB = 0x2E;
        public const uint FILE_DEVICE_KS = 0x2F;
        public const uint FILE_DEVICE_CHANGER = 0x30;
        public const uint FILE_DEVICE_SMARTCARD = 0x31;
        public const uint FILE_DEVICE_ACPI = 0x32;
        public const uint FILE_DEVICE_DVD = 0x33;
        public const uint FILE_DEVICE_FULLSCREEN_VIDEO = 0x34;
        public const uint FILE_DEVICE_DFS_FILE_SYSTEM = 0x35;
        public const uint FILE_DEVICE_DFS_VOLUME = 0x36;
        public const uint FILE_DEVICE_SERENUM = 0x37;
        public const uint FILE_DEVICE_TERMSRV = 0x38;
        public const uint FILE_DEVICE_KSEC = 0x39;
        public const uint FILE_DEVICE_FIPS = 0x3A;
        public const uint FILE_DEVICE_INFINIBAND = 0x3B;
        public const uint FILE_DEVICE_VMBUS = 0x3E;
        public const uint FILE_DEVICE_CRYPT_PROVIDER = 0x3F;
        public const uint FILE_DEVICE_WPD = 0x40;
        public const uint FILE_DEVICE_BLUETOOTH = 0x41;
        public const uint FILE_DEVICE_MT_COMPOSITE = 0x42;
        public const uint FILE_DEVICE_MT_TRANSPORT = 0x43;
        public const uint FILE_DEVICE_BIOMETRIC = 0x44;
        public const uint FILE_DEVICE_PMI = 0x45;
        public const uint FILE_DEVICE_EHSTOR = 0x46;
        public const uint FILE_DEVICE_DEVAPI = 0x47;
        public const uint FILE_DEVICE_GPIO = 0x48;
        public const uint FILE_DEVICE_USBEX = 0x49;
        public const uint FILE_DEVICE_CONSOLE = 0x50;
        public const uint FILE_DEVICE_NFP = 0x51;
        public const uint FILE_DEVICE_SYSENV = 0x52;
        public const uint FILE_DEVICE_VIRTUAL_BLOCK = 0x53;
        public const uint FILE_DEVICE_POINT_OF_SERVICE = 0x54;
        public const uint FILE_DEVICE_AVIO = 0x99;

        public const uint FILE_READ_DATA = (0x1);    // file & pipe
        public const uint FILE_LIST_DIRECTORY = (0x1);    // directory

        public const uint FILE_WRITE_DATA = (0x2);    // file & pipe
        public const uint FILE_ADD_FILE = (0x2);    // directory

        public const uint FILE_APPEND_DATA = (0x4);    // file
        public const uint FILE_ADD_SUBDIRECTORY = (0x4);    // directory
        public const uint FILE_CREATE_PIPE_INSTANCE = (0x4);    // named pipe

        public const uint FILE_READ_EA = (0x8);    // file & directory

        public const uint FILE_WRITE_EA = (0x10);    // file & directory

        public const uint FILE_EXECUTE = (0x20);    // file
        public const uint FILE_TRAVERSE = (0x20);    // directory

        public const uint FILE_DELETE_CHILD = (0x40);    // directory

        public const uint FILE_READ_ATTRIBUTES = (0x80);    // all

        public const uint FILE_WRITE_ATTRIBUTES = (0x100);    // all

        public const uint FILE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF);

        public const uint FILE_GENERIC_READ = (STANDARD_RIGHTS_READ |
                                           FILE_READ_DATA |
                                           FILE_READ_ATTRIBUTES |
                                           FILE_READ_EA |
                                           SYNCHRONIZE);

        public const uint FILE_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE |
                                           FILE_WRITE_DATA |
                                           FILE_WRITE_ATTRIBUTES |
                                           FILE_WRITE_EA |
                                           FILE_APPEND_DATA |
                                           SYNCHRONIZE);

        public const uint FILE_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE |
                                           FILE_READ_ATTRIBUTES |
                                           FILE_EXECUTE |
                                           SYNCHRONIZE);

        public const uint FILE_SHARE_READ = 0x1;
        public const uint FILE_SHARE_WRITE = 0x2;
        public const uint FILE_SHARE_DELETE = 0x4;

        public static readonly CTL_CODE FSCTL_REQUEST_OPLOCK_LEVEL_1 = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_REQUEST_OPLOCK_LEVEL_2 = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_REQUEST_BATCH_OPLOCK = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_OPLOCK_BREAK_ACKNOWLEDGE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_OPBATCH_ACK_CLOSE_PENDING = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_OPLOCK_BREAK_NOTIFY = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_LOCK_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_UNLOCK_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_DISMOUNT_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // decommissioned fsctl value                                              9
        public static readonly CTL_CODE FSCTL_IS_VOLUME_MOUNTED = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_IS_PATHNAME_VALID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS); // PATHNAME_BUFFER,

        public static readonly CTL_CODE FSCTL_MARK_VOLUME_DIRTY = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // decommissioned fsctl value                                             13
        public static readonly CTL_CODE FSCTL_QUERY_RETRIEVAL_POINTERS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_GET_COMPRESSION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_SET_COMPRESSION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA);

        // decommissioned fsctl value                                             17
        // decommissioned fsctl value                                             18
        public static readonly CTL_CODE FSCTL_SET_BOOTLOADER_ACCESSED = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_MARK_AS_SYSTEM_HIVE = FSCTL_SET_BOOTLOADER_ACCESSED;
        public static readonly CTL_CODE FSCTL_OPLOCK_BREAK_ACK_NO_2 = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_INVALIDATE_VOLUMES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_QUERY_FAT_BPB = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS); // FSCTL_QUERY_FAT_BPB_BUFFER

        public static readonly CTL_CODE FSCTL_REQUEST_FILTER_OPLOCK = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_FILESYSTEM_GET_STATISTICS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS); // FILESYSTEM_STATISTICS

        // if  (_WIN32_WINNT >= _WIN32_WINNT_NT4);
        public static readonly CTL_CODE FSCTL_GET_NTFS_VOLUME_DATA = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS); // NTFS_VOLUME_DATA_BUFFER

        public static readonly CTL_CODE FSCTL_GET_NTFS_FILE_RECORD = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS); // NTFS_FILE_RECORD_INPUT_BUFFER, NTFS_FILE_RECORD_OUTPUT_BUFFER

        public static readonly CTL_CODE FSCTL_GET_VOLUME_BITMAP = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS); // STARTING_LCN_INPUT_BUFFER, VOLUME_BITMAP_BUFFER

        public static readonly CTL_CODE FSCTL_GET_RETRIEVAL_POINTERS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS); // STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER

        public static readonly CTL_CODE FSCTL_MOVE_FILE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // MOVE_FILE_DATA,

        public static readonly CTL_CODE FSCTL_IS_VOLUME_DIRTY = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // decommissioned fsctl value                                             31
        public static readonly CTL_CODE FSCTL_ALLOW_EXTENDED_DASD_IO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS);

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_NT4 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN2K);
        // decommissioned fsctl value                                             33
        // decommissioned fsctl value                                             34
        public static readonly CTL_CODE FSCTL_FIND_FILES_BY_SID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS);

        // decommissioned fsctl value                                             36
        // decommissioned fsctl value                                             37
        public static readonly CTL_CODE FSCTL_SET_OBJECT_ID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // FILE_OBJECTID_BUFFER

        public static readonly CTL_CODE FSCTL_GET_OBJECT_ID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS); // FILE_OBJECTID_BUFFER

        public static readonly CTL_CODE FSCTL_DELETE_OBJECT_ID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);

        public static readonly CTL_CODE FSCTL_SET_REPARSE_POINT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // REPARSE_DATA_BUFFER,

        public static readonly CTL_CODE FSCTL_GET_REPARSE_POINT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS); // REPARSE_DATA_BUFFER

        public static readonly CTL_CODE FSCTL_DELETE_REPARSE_POINT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // REPARSE_DATA_BUFFER,

        public static readonly CTL_CODE FSCTL_ENUM_USN_DATA = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS); // MFT_ENUM_DATA,

        public static readonly CTL_CODE FSCTL_SECURITY_ID_CHECK = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, FILE_READ_DATA); // BULK_SECURITY_TEST_DATA,

        public static readonly CTL_CODE FSCTL_READ_USN_JOURNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS); // READ_USN_JOURNAL_DATA, USN

        public static readonly CTL_CODE FSCTL_SET_OBJECT_ID_EXTENDED = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);

        public static readonly CTL_CODE FSCTL_CREATE_OR_GET_OBJECT_ID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS); // FILE_OBJECTID_BUFFER

        public static readonly CTL_CODE FSCTL_SET_SPARSE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);

        public static readonly CTL_CODE FSCTL_SET_ZERO_DATA = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA); // FILE_ZERO_DATA_INFORMATION,

        public static readonly CTL_CODE FSCTL_QUERY_ALLOCATED_RANGES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, FILE_READ_DATA); // FILE_ALLOCATED_RANGE_BUFFER, FILE_ALLOCATED_RANGE_BUFFER

        public static readonly CTL_CODE FSCTL_ENABLE_UPGRADE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_DATA);

        public static readonly CTL_CODE FSCTL_SET_ENCRYPTION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS); // ENCRYPTION_BUFFER, DECRYPTION_STATUS_BUFFER

        public static readonly CTL_CODE FSCTL_ENCRYPTION_FSCTL_IO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_WRITE_RAW_ENCRYPTED = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS); // ENCRYPTED_DATA_INFO, EXTENDED_ENCRYPTED_DATA_INFO

        public static readonly CTL_CODE FSCTL_READ_RAW_ENCRYPTED = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS); // REQUEST_RAW_ENCRYPTED_DATA, ENCRYPTED_DATA_INFO, EXTENDED_ENCRYPTED_DATA_INFO

        public static readonly CTL_CODE FSCTL_CREATE_USN_JOURNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS); // CREATE_USN_JOURNAL_DATA,

        public static readonly CTL_CODE FSCTL_READ_FILE_USN_DATA = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, FILE_ANY_ACCESS); // Read the Usn Record for a file

        public static readonly CTL_CODE FSCTL_WRITE_USN_CLOSE_RECORD = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS); // Generate Close Usn Record

        public static readonly CTL_CODE FSCTL_EXTEND_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_QUERY_USN_JOURNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_DELETE_USN_JOURNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_MARK_HANDLE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_SIS_COPYFILE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_SIS_LINK_FILES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA);

        // decommissional fsctl value                                             66
        // decommissioned fsctl value                                             67
        // decommissioned fsctl value                                             68
        public static readonly CTL_CODE FSCTL_RECALL_FILE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS);

        // decommissioned fsctl value                                             70
        public static readonly CTL_CODE FSCTL_READ_FROM_PLEX = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA);

        public static readonly CTL_CODE FSCTL_FILE_PREFETCH = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // FILE_PREFETCH

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_WIN2K */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_VISTA);
        public static readonly CTL_CODE FSCTL_MAKE_MEDIA_COMPATIBLE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, FILE_WRITE_DATA); // UDFS R/W

        public static readonly CTL_CODE FSCTL_SET_DEFECT_MANAGEMENT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, FILE_WRITE_DATA); // UDFS R/W

        public static readonly CTL_CODE FSCTL_QUERY_SPARING_INFO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS); // UDFS R/W

        public static readonly CTL_CODE FSCTL_QUERY_ON_DISK_VOLUME_INFO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS); // C/UDFS

        public static readonly CTL_CODE FSCTL_SET_VOLUME_COMPRESSION_STATE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // VOLUME_COMPRESSION_STATE

        // decommissioned fsctl value                                                 80
        public static readonly CTL_CODE FSCTL_TXFS_MODIFY_RM = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_QUERY_RM_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, FILE_READ_DATA); // TxF

        // decommissioned fsctl value                                                 83
        public static readonly CTL_CODE FSCTL_TXFS_ROLLFORWARD_REDO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_ROLLFORWARD_UNDO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_START_RM = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_SHUTDOWN_RM = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_READ_BACKUP_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, FILE_READ_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_WRITE_BACKUP_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_CREATE_SECONDARY_RM = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_GET_METADATA_INFO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, FILE_READ_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_GET_TRANSACTED_VERSION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, FILE_READ_DATA); // TxF

        // decommissioned fsctl value                                                 93
        public static readonly CTL_CODE FSCTL_TXFS_SAVEPOINT_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        public static readonly CTL_CODE FSCTL_TXFS_CREATE_MINIVERSION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, FILE_WRITE_DATA); // TxF

        // decommissioned fsctl value                                                 96
        // decommissioned fsctl value                                                 97
        // decommissioned fsctl value                                                 98
        public static readonly CTL_CODE FSCTL_TXFS_TRANSACTION_ACTIVE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, FILE_READ_DATA); // TxF

        public static readonly CTL_CODE FSCTL_SET_ZERO_ON_DEALLOCATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);

        public static readonly CTL_CODE FSCTL_SET_REPAIR = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_GET_REPAIR = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_WAIT_FOR_REPAIR = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // decommissioned fsctl value                                                 105
        public static readonly CTL_CODE FSCTL_INITIATE_REPAIR = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSC_INTERNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER, FILE_ANY_ACCESS); // CSC internal implementation

        public static readonly CTL_CODE FSCTL_SHRINK_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); // SHRINK_VOLUME_INFORMATION

        public static readonly CTL_CODE FSCTL_SET_SHORT_NAME_BEHAVIOR = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_DFSR_SET_GHOST_HANDLE_STATE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS);

        //
        //  Values 111 - 119 are reserved for FSRM.
        //

        public static readonly CTL_CODE FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_READ_DATA); // TxF
        public static readonly CTL_CODE FSCTL_TXFS_LIST_TRANSACTIONS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, FILE_READ_DATA); // TxF

        public static readonly CTL_CODE FSCTL_QUERY_PAGEFILE_ENCRYPTION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_VISTA);
        public static readonly CTL_CODE FSCTL_RESET_VOLUME_ALLOCATION_HINTS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN7);
        public static readonly CTL_CODE FSCTL_QUERY_DEPENDENT_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, FILE_ANY_ACCESS);   // Dependency File System Filter

        public static readonly CTL_CODE FSCTL_SD_GLOBAL_CHANGE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, FILE_ANY_ACCESS); // Query/Change NTFS Security Descriptors

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_VISTA);
        public static readonly CTL_CODE FSCTL_TXFS_READ_BACKUP_INFORMATION2 = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, FILE_ANY_ACCESS); // TxF

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN7);
        public static readonly CTL_CODE FSCTL_LOOKUP_STREAM_FROM_CLUSTER = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_TXFS_WRITE_BACKUP_INFORMATION2 = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, FILE_ANY_ACCESS); // TxF

        public static readonly CTL_CODE FSCTL_FILE_TYPE_NOTIFICATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN8);
        public static readonly CTL_CODE FSCTL_FILE_LEVEL_TRIM = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, FILE_WRITE_DATA);

        // endif  /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */

        //
        //  Values 131 - 139 are reserved for FSRM.
        //

        //public static readonly CTL_CODE FSCTL_LOCK_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS);
        //public static readonly CTL_CODE FSCTL_UNLOCK_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS);
        //public static readonly CTL_CODE FSCTL_DISMOUNT_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS);


        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN7);
        public static readonly CTL_CODE FSCTL_GET_BOOT_AREA_INFO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, FILE_ANY_ACCESS); // BOOT_AREA_INFO

        public static readonly CTL_CODE FSCTL_GET_RETRIEVAL_POINTER_BASE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS); // RETRIEVAL_POINTER_BASE

        public static readonly CTL_CODE FSCTL_SET_PERSISTENT_VOLUME_STATE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, FILE_ANY_ACCESS); // FILE_FS_PERSISTENT_VOLUME_INFORMATION

        public static readonly CTL_CODE FSCTL_QUERY_PERSISTENT_VOLUME_STATE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, FILE_ANY_ACCESS); // FILE_FS_PERSISTENT_VOLUME_INFORMATION

        public static readonly CTL_CODE FSCTL_REQUEST_OPLOCK = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_TUNNEL_REQUEST = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, FILE_ANY_ACCESS); // CSV_TUNNEL_REQUEST

        public static readonly CTL_CODE FSCTL_IS_CSV_FILE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, FILE_ANY_ACCESS); // IS_CSV_FILE

        public static readonly CTL_CODE FSCTL_QUERY_FILE_SYSTEM_RECOGNITION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, FILE_ANY_ACCESS); //

        public static readonly CTL_CODE FSCTL_CSV_GET_VOLUME_PATH_NAME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 150, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_IS_FILE_ON_CSV_VOLUME = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 151, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN8);
        public static readonly CTL_CODE FSCTL_CORRUPTION_HANDLING = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_OFFLOAD_READ = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS);

        public static readonly CTL_CODE FSCTL_OFFLOAD_WRITE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS);

        // endif  /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN7);
        public static readonly CTL_CODE FSCTL_CSV_INTERNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 155, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN8);
        public static readonly CTL_CODE FSCTL_SET_PURGE_FAILURE_MODE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_QUERY_FILE_LAYOUT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_IS_VOLUME_OWNED_BYCSVFS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 158, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_GET_INTEGRITY_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS);                  // FSCTL_GET_INTEGRITY_INFORMATION_BUFFER

        public static readonly CTL_CODE FSCTL_SET_INTEGRITY_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA); // FSCTL_SET_INTEGRITY_INFORMATION_BUFFER

        public static readonly CTL_CODE FSCTL_QUERY_FILE_REGIONS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */

        //
        // Dedup FSCTLs
        // Values 162 - 170 are reserved for Dedup.
        //

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN8);
        public static readonly CTL_CODE FSCTL_DEDUP_FILE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_DEDUP_QUERY_FILE_HASHES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 166, METHOD_NEITHER, FILE_READ_DATA);

        public static readonly CTL_CODE FSCTL_DEDUP_QUERY_RANGE_STATE = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 167, METHOD_NEITHER, FILE_READ_DATA);

        public static readonly CTL_CODE FSCTL_DEDUP_QUERY_REPARSE_INFO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 168, METHOD_NEITHER, FILE_ANY_ACCESS);

        // endif  /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WIN8);
        public static readonly CTL_CODE FSCTL_RKF_INTERNAL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER, FILE_ANY_ACCESS); // Resume Key Filter

        public static readonly CTL_CODE FSCTL_SCRUB_DATA = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_REPAIR_COPIES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA);

        public static readonly CTL_CODE FSCTL_DISABLE_LOCAL_BUFFERING = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_MGMT_LOCK = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_ADVANCE_FILE_ID = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_SYNC_TUNNEL_REQUEST = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_WRITE_USN_REASON = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_CONTROL = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_GET_REFS_VOLUME_DATA = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_CSV_H_BREAKING_SYNC_TUNNEL_REQUEST = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 185, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */

        // if  (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE);
        public static readonly CTL_CODE FSCTL_QUERY_STORAGE_CLASSES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 187, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_QUERY_REGION_INFO = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 188, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_USN_TRACK_MODIFIED_RANGES = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 189, METHOD_BUFFERED, FILE_ANY_ACCESS); // USN_TRACK_MODIFIED_RANGES

        // endif  /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */
        // if  (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE);
        public static readonly CTL_CODE FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 192, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_SVHDX_SYNC_TUNNEL_REQUEST = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 193, METHOD_BUFFERED, FILE_ANY_ACCESS);

        public static readonly CTL_CODE FSCTL_SVHDX_SET_INITIATOR_INFORMATION = new CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 194, METHOD_BUFFERED, FILE_ANY_ACCESS);

        // endif  /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */
        //
        // AVIO IOCTLS.
        //

        public static readonly CTL_CODE IOCTL_AVIO_ALLOCATE_STREAM = new CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);

        public static readonly CTL_CODE IOCTL_AVIO_FREE_STREAM = new CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);

        public static readonly CTL_CODE IOCTL_AVIO_MODIFY_STREAM = new CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS);
    }
}
